<?php
/**
 * ------------------------------------------------------------------------
 * JA Disqus Debate Echo plugin for Joomla 2.5
 * ------------------------------------------------------------------------
 * Copyright (C) 2004-2011 J.O.O.M Solutions Co., Ltd. All Rights Reserved.
 * @license - GNU/GPL, http://www.gnu.org/licenses/gpl.html
 * Author: J.O.O.M Solutions Co., Ltd
 * Websites: http://www.joomlart.com - http://www.joomlancers.com
 * ------------------------------------------------------------------------
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

//Disqus config
$subdomain      = $this->plgParams->get('provider-disqus-subdomain');
$devmode        = $this->plgParams->get('provider-disqus-devmode',0);

$devcode = "";
if ($devmode)
	$devcode = "var disqus_developer = \"1\";";

$sefUrl = $this->_sefurl;
if ($this->isComment == false) {
?>
	<div class="jacomment-count">
    <a class="jacomment-counter" href="<?php echo $this->_sefurl; ?>#disqus_thread" onclick="location.href='<?php echo $this->_url; ?>#disqus_thread'; return false;" title="">
	<?php echo JText::_("COMMENTS"); ?>
    </a>
    </div>
<?php
} else {
	if(!defined("JA_EMBEDED_DISQUS_FORM")):
		define("JA_EMBEDED_DISQUS_FORM", 1);
?>
    <div id="disqus_thread"></div>
	<script type="text/javascript">
      /**
        * var disqus_identifier; [Optional but recommended: Define a unique identifier (e.g. post id or slug) for this thread]
        */
		<?php echo $devcode?>

		var disqus_url= "<?php echo $sefUrl; ?>";
		var disqus_identifier = "<?php echo $this->_postid ?>";
      (function() {
       var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
       dsq.src = 'http://<?php echo $subdomain; ?>.disqus.com/embed.js';
       (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
      })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript=<?php echo $subdomain; ?>">comments powered by Disqus.</a></noscript>
	<a href="http://disqus.com" class="dq-powered"><?php echo JText::_("BLOG COMMENTS POWERED BY DISQUS"); ?></a>
<?php
	endif;
}
?>